package com.chb.docter.controller.apis;

import com.chb.docter.dto.RegistrationDto;
import com.chb.docter.params.SchedulingAndPatientParam;
import com.chb.docter.params.SchedulingParam;
import com.chb.docter.params.SchedulingSaveParam;
import com.chb.docter.service.SchedulingService;
import com.hos.entity.his.Scheduling;
import com.hos.entity.sys.User;
import com.hos.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author: 陈海彬
 * @date: Created in 2023/12/11 19:26
 * @description:
 * @modified By:
 * @version:
 */
@RestController
@RequestMapping("docter/api/scheduling")
@Api(value = "医生排班相关接口", tags = "医生排班相关接口")
@Slf4j
public class ApiSchedulingController {


    @Resource
    private SchedulingService schedulingService;


    @PostMapping
    @ApiOperation(value = "获取医生排班的表格信息", httpMethod = "POST")
    public Result<Map<String, Object>> getSchedulingList(@RequestBody SchedulingParam schedulingParam) {
        return schedulingService.getSchedulingList(schedulingParam);
    }

    @PostMapping("queryMyScheduling")
    @ApiOperation("查询我的排班")
    public Result<Map<String, Object>> queryMyScheduling(@RequestBody SchedulingParam schedulingParam) {
        return schedulingService.queryMyScheduling(schedulingParam);
    }

    @PostMapping("AppQueryMyScheduling")
    @ApiOperation("App查询我的排班")
    public Result<Map<String, Object>> AppQueryMyScheduling(@RequestBody SchedulingParam schedulingParam) {
        return schedulingService.AppQueryMyScheduling(schedulingParam);
    }


    @PostMapping("/saveScheduling")
    @ApiOperation(value = "保存排班信息", httpMethod = "POST")
    public Result<Void> saveScheduling(@RequestBody SchedulingSaveParam data) {
        boolean flag = schedulingService.saveScheduling(data);
        if (flag) {
            return new Result<>(200, "操作成功", null);
        }
        return new Result<>(500, "服务器正忙，请稍后重试", null);
    }


    @PostMapping("/findSchedulingList")
    @ApiOperation(value = "根据条件查询排班信息")
    public Result<List<RegistrationDto>> findSchedulingList(@RequestBody SchedulingAndPatientParam params) {
        return new Result<>(200, "操作成功", schedulingService.findSchedulingList(params));
    }

    @GetMapping("queryUsersNeedScheduling")
    @ApiOperation("查询需要排班的用户列表 可以传部门ID 如果部门ID为空，则直接显示所有")
    public Result<List<User>> queryUsersNeedScheduling(Long deptId) {
        return new Result<>(200, "查询成功", schedulingService.queryUsersNeedScheduling(deptId));
    }
}